package com.cgs.springboottes2secrity.repository;

import com.cgs.springboottes2secrity.entity.Admin;
import com.cgs.springboottes2secrity.entity.Auth;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author cgs
 * @version woNiu 98
 * @date 2023/5/10 10:59
 */
@Repository
public interface AuthRepository extends JpaRepository<Auth,Integer> {
    /**
     * fetch data
     * @return List<Auth>
     * @param adminId account
     */
    @Query(value = "select * from auth a,user_auth ua " +
            "where a.id=ua.auth_id and ua.admin_id=?1", nativeQuery = true)
    List<Auth> getByAdminId(Integer adminId);
}
